home *** CD-ROM | disk | FTP | other *** search
/ Network Support Library / RoseWare - Network Support Library.iso / apidev / dax1.exe / DAP / DAPE / DAPINIT.C next >
Text File  |  1992-07-15  |  4KB  |  105 lines

  1. //   ╔════════════════════════════════════════════════════════════════════╗
  2. //   ║                                                                    ║
  3. //   ║ module:      dapinit.c                                             ║
  4. //   ║ abstract:    This module contains the initialization code for DAP  ║
  5. //   ║                                                                    ║
  6. //   ║ environment: NetWare 3.x v3.11                                     ║
  7. //   ║              Network C for NLMs SDK                                ║
  8. //   ║              CLib v3.11                                            ║
  9. //   ║                                                                    ║
  10. //   ║  This software is provided as is and carries no warranty           ║
  11. //   ║  whatsoever.  Novell disclaims and excludes any and all implied    ║
  12. //   ║  warranties of merchantability, title and fitness for a particular ║
  13. //   ║  purpose.  Novell does not warrant that the software will satisfy  ║
  14. //   ║  your requirements or that the software is without defect or error ║
  15. //   ║  or that operation of the software will be uninterrupted.  You are ║
  16. //   ║  using the software at your risk.  The software is not a product   ║
  17. //   ║  of Novell, Inc. or any of subsidiaries.                           ║
  18. //   ║                                                                    ║
  19. //   ╟────────────────────────────────────────────────────────────────────╢
  20. //   ║ maintenance history:                                               ║
  21. //   ║ level    date      pi   description                                ║
  22. //   ╟────────────────────────────────────────────────────────────────────╢
  23. //   ║  001   02/24/92    kl   initial release.                           ║
  24. //   ╚════════════════════════════════════════════════════════════════════╝
  25.  
  26. //
  27. //  This could be a library NLM too.
  28. //
  29.  
  30. #include    <stdio.h>
  31. #include    <process.h>
  32. #include    <library.h>
  33.  
  34. #include    "dap/dapsys.h"
  35. #include    "cp/cpapi.h"
  36. #include    "h/appl.h"
  37.  
  38. STATIC  int     dapInited = FALSE;
  39.  
  40. T_RC    DAPInitialize(char *server, WORD type)
  41. {
  42.         if( dapInited ){
  43.             DIAG2("Initialized called multiple times");
  44.             return DAP_SUCCESS;
  45.         }
  46.         dapInited = TRUE;
  47.         //
  48.         //  First, get the screen IO APIs ready.
  49.         //  Then, prepare to receive requests,
  50.         //  send replies, and maintain sessions.
  51.         //
  52.         //!!  Make sure these don't return until they are ready.
  53.         //
  54.         if( DAPInitializeIOLogic() )            return DAP_INITFAILED;
  55.         else if( DAPInitializeRecvLogic() )     return DAP_INITFAILED;
  56.         else if( DAPInitializeSendLogic() )     return DAP_INITFAILED;
  57.         else if( DAPInitializeSessLogic() )     return DAP_INITFAILED;
  58.         else if( DAPInitializeStatLogic() )     return DAP_INITFAILED;
  59.         //
  60.         //  Finally, start the CP Layer engine.  This will start the
  61.         //  service advertising.
  62.         //
  63.         else if(CPInitialize(server,type,DAPEnqueueServiceRequest,DAPprintf))
  64.             return DAP_INITFAILED;
  65.  
  66.         return DAP_SUCCESS;
  67. }
  68.  
  69. void    DAPDeInitialize()
  70. {
  71.         if( dapInited ){
  72.             //
  73.             //  DeInitialize the CP Layer first, so it won't send any
  74.             //  more messages to the DAP layer...
  75.             //
  76.             CPDeInitialize();
  77.             //
  78.             //  Now, shut down the DAP engine.
  79.             //
  80.             //!!  Each of these should not return until they have
  81.             //!!  completely shut themselves down...
  82.             //
  83.             DAPDeInitializeSendLogic();
  84.             DAPDeInitializeRecvLogic();
  85.             DAPDeInitializeSessLogic();
  86.             DAPDeInitializeStatLogic();
  87.             DAPDeInitializeIOLogic();
  88.             dapInited = FALSE;
  89.         }
  90.         else{
  91.             DIAG2("DeInitialize DAP called multiple times");
  92.         }
  93. }
  94.  
  95. main()
  96. {
  97.         atexit(DAPDeInitialize);
  98.         if( DAPInitialize(SERVERNAME, SERVERTYPE) ){
  99.             printf("Could not initialize DAP...\n");
  100.             exit(1);
  101.         }
  102.         xDIAG1(RenameThread(GetThreadID(),"DAP_INIT"));
  103.         while(1) SuspendThread(GetThreadID());
  104. }
  105.